package com.charlie.beans;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Вова
 */
@Entity
@Table(name = "GROUPS_ROLES")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "GroupsRoles.findAll", query = "SELECT g FROM GroupsRoles g"),
    @NamedQuery(name = "GroupsRoles.findByGroupsRolesId", query = "SELECT g FROM GroupsRoles g WHERE g.groupsRolesId = :groupsRolesId")})
public class GroupsRoles implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "GROUPS_ROLES_SEQ")
    @SequenceGenerator(name = "GROUPS_ROLES_SEQ", sequenceName = "GROUPS_ROLES_GROUPS_ROLES_ID", allocationSize = 1)
    @Column(name = "GROUPS_ROLES_ID")
    private Integer groupsRolesId;
    @JoinColumn(name = "ROLES_ID", referencedColumnName = "ROLES_ID")
    @ManyToOne(optional = false)
    private Roles rolesId;
    @JoinColumn(name = "GROUPS_ID", referencedColumnName = "GROUPS_ID")
    @ManyToOne(optional = false)
    private Groups groupsId;

    public GroupsRoles() {
    }

    public GroupsRoles(Integer groupsRolesId) {
        this.groupsRolesId = groupsRolesId;
    }

    public Integer getGroupsRolesId() {
        return groupsRolesId;
    }

    public void setGroupsRolesId(Integer groupsRolesId) {
        this.groupsRolesId = groupsRolesId;
    }

    public Roles getRolesId() {
        return rolesId;
    }

    public void setRolesId(Roles rolesId) {
        this.rolesId = rolesId;
    }

    public Groups getGroupsId() {
        return groupsId;
    }

    public void setGroupsId(Groups groupsId) {
        this.groupsId = groupsId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (groupsRolesId != null ? groupsRolesId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GroupsRoles)) {
            return false;
        }
        GroupsRoles other = (GroupsRoles) object;
        if ((this.groupsRolesId == null && other.groupsRolesId != null) || (this.groupsRolesId != null && !this.groupsRolesId.equals(other.groupsRolesId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.charlie.beans.GroupsRoles[ groupsRolesId=" + groupsRolesId + " ]";
    }
    
}
